package com.eshop.we.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.eshop.we.business.SuggestBusiness;
import com.eshop.we.result.Result;
import com.eshop.we.suggest.dto.SuggestDto;
import com.eshop.we.suggest.entity.Suggest;
import com.eshop.we.user.dto.UserInfoDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/suggest")
public class SuggestController extends BaseController {

    @Autowired
    SuggestBusiness suggestBusiness;

    @GetMapping("/getsuggestpage")
    public Result  getSuggestPage(@RequestParam(required = false)String name,@RequestParam(required = false)String mobile,
                                  @RequestParam(required = false)String startDate,@RequestParam(required = false)String endDate,
                                  @RequestParam(required = false,defaultValue = "1")Integer pageNum,@RequestParam(required = false,defaultValue = "20")Integer pageSize){
        Page<SuggestDto> page=new Page<>(pageNum,pageSize);
        page=suggestBusiness.selectSuggestPage(page,name,mobile,startDate,endDate);
        return Result.success(page);
    }

    @GetMapping("/getsuggestinfo")
    public Result getSuggestInfo(@RequestParam(required = true)Integer suggestId){
        Suggest suggest=new Suggest();
        suggest.setId(suggestId);
        return  Result.success(suggestBusiness.selectById(suggest));
    }

    @PostMapping("/addsuggestsolve")
    public Result addSuggestSolve(@RequestParam(required = true)Integer suggestId,@RequestParam(required = true)String feedback){
        Suggest suggest=new Suggest();
        suggest.setId(suggestId);
        suggest.setFeedback(feedback);
        return  Result.success(suggestBusiness.updateById(suggest));
    }
}
